import { configToSearch, toSearchHandle } from '@/views/datacenter/business/utils/index'
const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{ label: '养老机构', prop: 'organizationName' },
		{
			label: '巡查类型',
			prop: 'patrolType',
			propName: 'patrolTypeLabel',
			code: 'PATROL_TYPE',
			api: 'getDictItemList',
			type: 'remoteSelect',
		},
		{ label: '巡查内容', prop: 'patrolContent' },
		{ label: '巡查结果', prop: 'patrolResult' },
		{ label: '巡查人', prop: 'patrolUserName' },
		{ label: '巡查时间', prop: 'patrolDate' },
		{
			label: '是否可信',
			prop: 'isBelievable',
			custome: 'tag',
			dicData: [
				{ label: '否', value: 0,type:'danger'  },
				{ label: '是', value: 1,type:'success' },
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const detailConfig = {
	inline: false,
	showBtn: false,
	labelPosition: 'left',
	column: [
		{
			label: '服务组织机构名称',
			prop: 'organizationName',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '机构统一社会信用代码',
			prop: 'creditCode',
			type: 'text',
			maxlength: '18',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '巡查类型',
			prop: 'patrolType',
			propName: 'patrolTypeLabel',
			code: 'PATROL_TYPE',
			api: 'getDictItemList',
			type: 'remoteSelect',
			span: 8,
		},
		{
			label: '巡查内容',
			prop: 'patrolContent',
			type: 'text',
			maxlength: '500',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '巡查结果',
			prop: 'patrolResult',
			type: 'text',
			maxlength: '500',
			showWordLimit: true,
			span: 8,
		},
		{ label: '签字图片', prop: 'signImg', span: 8, custome: 'file' },
		{
			label: '巡查人',
			prop: 'patrolUserName',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '巡查时间',
			prop: 'patrolDate',
			type: 'datetime',
			format: 'YYYY年MM月DD日 HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 8,
		},
	],
}
const moreSearchConfig: any = {
	inline: true,
	showBtn: false,
	labelPosition: 'left',
	column: [...configToSearch(detailConfig.column)],
}
export const importConfig = {
	tabSteps: [
		{
			label: '下载模板',
			download: '下载模板',
			active: 1,
			rules: [
				{
					label: '下载最新导入模板。共1个：',
					children: [
						{
							label: '《巡查记录》',
							link: true,
							url: 'view_dpOrgPatrolRecord_downloadTemplate',
						},
					],
				},
			],
		},
		{
			label: '导入信息',
			description: '',
			uploadTip: '巡查记录表',
			active: 2,
			url: 'view_dpOrgPatrolRecord_import',
			code: 3030,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
	],
	dataType: 89,
}

export const baseConfig = {
	pageName: '巡查记录',
	dictcodes: ['PATROL_TYPE'],
	rowKey: 'id',
	tipLabel: 'patrolUserName',
	paramsObj: {
		code: 3030,
	},
	exportMqTopic: '/ning/export/',
	api: {
		moreSearch: 'view_dpOrgPatrolRecord_search',
		index: 'view_dpOrgPatrolRecord_page',
		import: 'view_dpOrgPatrolRecord_import',
		export: 'view_dpOrgPatrolRecord_export',
		delete: 'view_dpOrgPatrolRecord_del',
		detail: 'view_dpOrgPatrolRecord_view',
	},
	auth: {
		index: 'view_dpOrgPatrolRecord_page',
		// import: 'view_dpOrgPatrolRecord_import',
		// export: 'view_dpOrgPatrolRecord_export',
		delete: 'view_dpOrgPatrolRecord_del',
		detail: 'view_dpOrgPatrolRecord_view',
		mulitSet: 'mulitSet',
	},
	menuBtn: [
		{
			icon: 'detail',
			label: '查看详情',
			type: 'primary',
			operate: 'detail',
			auth: 'view_dpEquipWarn_page',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '80%',
	},
	moreSearchConfig,
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{ label: '巡查内容', prop: 'patrolContent', type: 'input', span: 6 },
			{ label: '巡查结果', prop: 'patrolResult', type: 'input', span: 6 },
			{ label: '巡查人', prop: 'patrolUserName', type: 'input', span: 6 },
			{
				label: '巡查类型',
				prop: 'patrolType',
				propName: 'patrolTypeLabel',
				type: 'remoteSelect',
				code: 'PATROL_TYPE',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				span: 6,
			},
		],
	},
	importConfig,
	tableConfig,
	detailConfig,
	beforeOnLoadFormate: async (params) => {
		params = toSearchHandle(moreSearchConfig, {}, params)

		return Promise.resolve({
			...params,
		})
	},
}
